package org.youyun56.gpsserver.command;

import net.sf.json.JSONObject;

import org.youyun56.gpsserver.Task;
import org.youyun56.gpsserver.common.SessionKey;
import org.youyun56.gpsserver.entity.Car;

import com.j3.sql.SqlFunc;

public class ChangeCarHearvyExecutor extends Task {

    @Override
    public Object execute() throws Exception {
        String hearvy = command.getParameters().get("hearvy");
        SqlFunc fun = new SqlFunc();
        Car car = (Car) command.getSession().getAttribute(SessionKey.CAR);
        JSONObject o = new JSONObject();
        o.put("id", CommandType.Change_Car_Hearvy);
        o.put(JSONKey.SUCCESS, fun.executeUpdate(String.format("update car set carryStatus = '%s' where id = %d", hearvy, car.getId())) > 0);
        o.put("hearvy", hearvy);
        return o;
    }

}
